import SafeCall from "./SafeCall";

export default function (start, end, delay = 500) {
    let timer = null

    return {
        debounce: () => {
            timer == null ? SafeCall(start) : clearTimeout(timer)
            timer = setTimeout(() => SafeCall(end, () => timer = null), delay)
        },
        clear: () => clearTimeout(timer),
    }
}
